This page will display some plotly plots based on specific dataset.

plotly plots

plotly

load datasets

Tidy the dataset by selecting variables needed and restrict order number to a ramge of 5 to 60.

library(tidyverse)
library(p8105.datasets)
library(plotly)
library(flexdashboard)
data("instacart")

instacart = 
  instacart%>% 
  janitor::clean_names()%>%
  select(
    product_id,product_name,order_number, order_hour_of_day, department) %>%
    filter(order_number %in% 5:60)

Displaying order number distribution of products based on department applying boxplot

instacart %>% 
  plot_ly(y = ~order_number, color = ~department, type = "box", colors = "viridis")

scatter plot for order number during different hour of the day

instacart %>%
  filter(department %in% c("beverage","frozen"))%>%
  plot_ly(
    x = ~order_hour_of_day, y = ~order_number, type = "scatter", mode = "markers",
    color = ~department, alpha = 0.3)
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

bar chart showing order count distribution for snacks based on product name

 instacart %>% 
  filter(department %in% c("snacks"))%>%
  plot_ly(x = ~product_name, y = ~order_number, type = 'bar')